/*
 * 权限
 *
 * @Author:    zhoujk
 * @Date:      2022-09-06 20:00:40
 */

import { useUserStore } from '/@/store/modules/system/user'
import _ from 'lodash'

export function privilegeDirective(el, binding) {
  // 超级管理员
  if (useUserStore().superFlag) {
    return true
  }
  // 获取功能点权限
  let userPointsList = useUserStore().getPointList
  if (!userPointsList) {
    return false
  }
  // 如果有权限，删除节点
  if (!_.some(userPointsList, ['permission', binding.value])) {
    el.parentNode.removeChild(el)
  }
  return true
}
